import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		new Main(args);
	}

	public Main(String[] args)
	{
		if(args.length != 1)
		{
			System.err.println("Usage `java Main FILE`");
			return;
		}

		// Initiate algorithms
		PathAlg greedy1 = new GreedyAlgorithmPrimm();
		PathAlg greedy2 = new GreedyAlgorithmKruskal();
		PathAlg exhaustive = new ExhaustiveAlgorithm();
		
		// Set up graphs
		greedy1.buildGraph(args[0]);
		greedy2.buildGraph(args[0]);
		exhaustive.buildGraph(args[0]);

		// Run algorithms and print
		long timeGreedy1 = greedy1.runAlgorithmTimed();
		printAlgorithm(greedy1);
		
		long timeGreedy2 = greedy2.runAlgorithmTimed();
		printAlgorithm(greedy2);
		
		long timeExhaustive = exhaustive.runAlgorithmTimed();
		printAlgorithm(exhaustive);
	}

	private void printAlgorithm(PathAlg alg)
	{
		System.out.println("=== Running " + alg.getName() + " === ");
		System.out.print("Min. EL: "
			+ alg.getExpectedLatency() + "\nPath: ");
		for(int i : alg.getPath())
		{
			System.out.print((i+1) + " ");
		}

		System.out.println("\nExecution time in ms: " + alg.getTime());
		System.out.println();
	}
}

